// 1. 安装  npm init  npm i mongoose

// 2. 导入 config配置项
const config = require('../config/db.config');
const mongoose = require('mongoose');
// 3. 建立链接
mongoose.connect(`mongodb://${config.host}:${config.port}/${config.dbname}`);
// 4. 打开链接
mongoose.connection.on('open',()=>{
    console.log('链接数据库成功');
})
module.exports = mongoose;